|
RAIS
3.2
|
00001 using System; 00002 using System.Data; 00003 using System.Configuration; 00004 using System.Collections; 00005 using System.Web; 00006 using System.Web.Security; 00007 using System.Web.UI; 00008 using System.Web.UI.WebControls; 00009 using System.Web.UI.WebControls.WebParts; 00010 using System.Web.UI.HtmlControls; 00011 00012 using RAIS.Common.DynamicMaskManagement; 00013 using RAIS.Common.TableManagement; 00014 using RAIS.Common.UserManagement; 00015 using RAIS.UI.Common; 00016 00017 using FunctionRoleCategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Category>; 00018 using FunctionRoleSubcategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Subcategory>; 00019 using Masks = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Mask>; 00020 00021 namespace RAIS.UI.SpecificMasks 00022 { 00026 public partial class CustomTables2_New : System.Web.UI.Page 00027 { 00028 //********************************************************************* 00029 #region Private properties 00030 00033 protected UserData CurrentUser 00034 { 00035 get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; } 00036 } 00040 private FunctionRole.Category SelectedCategory 00041 { 00042 get 00043 { 00044 FunctionRoleCategories categories = RAIS.ApplicationLogicLayer.UserManagement.FunctionalRoleCategories; 00045 if (categories != null && categories.ContainsKey(this.DDLcategory.SelectedValue)) 00046 return categories[this.DDLcategory.SelectedValue]; 00047 else 00048 return null; 00049 } 00050 } 00054 private FunctionRole.Subcategory SelectedSubcategory 00055 { 00056 get 00057 { 00058 FunctionRoleSubcategories subcategories = UI.Common.TableManagement.GetFunctionRoleSubcategoriesByCategory(this, this.SelectedCategory, this.ShowProtectors, this.ShowEvaluators, false); 00059 if (subcategories != null && subcategories.ContainsKey(this.DDLsubcategory.SelectedValue)) 00060 return subcategories[this.DDLsubcategory.SelectedValue]; 00061 else 00062 return null; 00063 } 00064 } 00068 private Mask SelectedMask 00069 { 00070 get 00071 { 00072 Masks masks = RAIS.ApplicationLogicLayer.UserManagement.GetMasksWithoutAll(this.SelectedCategory, this.SelectedSubcategory); 00073 if (masks != null && masks.ContainsKey(this.DDLmask.SelectedValue)) 00074 return masks[this.DDLmask.SelectedValue]; 00075 else 00076 return null; 00077 } 00078 } 00082 private TableGroup SelectedTableGroup 00083 { 00084 get 00085 { 00086 TableGroup tableGroup = null; 00087 if (this.Session[Constants.SAVED_GROUP_TAG] != null) 00088 tableGroup = ((TableGroup)this.Session[Constants.SAVED_GROUP_TAG]); 00089 00090 return tableGroup; 00091 } 00092 } 00096 private RAIS.Common.TableManagement.Table.TableType SelectedTableType 00097 { 00098 get { return RAIS.Common.TableManagement.Table.TableTypesDictionary[DDLtabletype.SelectedValue].Type; } 00099 } 00103 private DynamicMask.DynamicMaskType? SelectedDynamicMaskType 00104 { 00105 get { return DynamicMask.GetTypeByVisibleName(this.DDLdynamicMaskType.SelectedValue); } 00106 } 00110 protected bool ShowHidden 00111 { 00112 get 00113 { 00114 //if (this.Session[UI.Common.Constants.SHOW_HIDDEN_STATE_TAG] != null) 00115 // return (bool)this.Session[UI.Common.Constants.SHOW_HIDDEN_STATE_TAG]; 00116 //else 00117 // return false; 00118 return UI.Common.PageManagement.GetShowProtectors(this) 00119 || UI.Common.PageManagement.GetShowEvaluators(this); 00120 } 00121 set 00122 { 00123 this.Session[UI.Common.Constants.SHOW_HIDDEN_STATE_TAG] = value; 00124 } 00125 } 00129 protected bool ShowProtectors 00130 { 00131 get 00132 { 00133 return UI.Common.PageManagement.GetShowProtectors(this); 00134 } 00135 } 00139 protected bool ShowEvaluators 00140 { 00141 get 00142 { 00143 return UI.Common.PageManagement.GetShowEvaluators(this); 00144 } 00145 } 00146 #endregion Private properties 00147 //********************************************************************* 00148 #region Event handlers 00149 protected void Page_PreLoad(object sender, EventArgs e) 00150 { 00151 RAIS.UI.Common.PageManagement.TrimTextBoxValues(this); 00152 } 00153 protected void Page_Load(object sender, EventArgs e) 00154 { 00155 this.Response.Cache.SetNoStore(); 00156 if (this.CurrentUser == null) 00157 UI.Common.AccessManagement.SignOut(this); 00158 this.LBLresult.Text = string.Empty; 00159 00160 if (!this.IsPostBack) 00161 { 00162 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name; 00163 this.TXTtablename.MaxLength = RAIS.Common.Constants.SMALL_FIELD_MAX_LENGTH; 00164 00165 UI.Common.TableManagement.InitializeTableTypeList(this.DDLtabletype); 00166 UI.Common.TableManagement.InitializeCategoryList(this.DDLcategory); 00167 this.DDLcategory.Items.Remove(this.DDLcategory.Items.FindByValue(RAIS.Common.Constants.CATEGORY_NAME_QUERY)); 00168 this.DDLcategory.Items.Remove(this.DDLcategory.Items.FindByValue(RAIS.Common.Constants.CATEGORY_NAME_STATISTICS)); 00169 UI.Common.TableManagement.InitializeSubcategoryListByCategory(this.DDLsubcategory, this.SelectedCategory, this.ShowProtectors, this.ShowEvaluators); 00170 UI.Common.TableManagement.InitializeDynamicMaskTypeList(this.DDLdynamicMaskType, true); 00171 00172 UI.Common.PageManagement.InitializePage(this, this.TreeView1); 00173 // this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest); 00174 00175 this.SetControllsProperties(); 00176 this.SetFocus(this.TXTtablename); 00177 00178 UI.Common.UserManagement.EnableCommonControls(this, false); 00179 } 00180 PageManagement.InitHelpMainMenu(LBTNdefault); 00181 } 00188 protected void DDLcategory_SelectedIndexChanged(object sender, EventArgs e) 00189 { 00190 UI.Common.TableManagement.InitializeSubcategoryListByCategory(this.DDLsubcategory, this.SelectedCategory, this.ShowProtectors, this.ShowEvaluators); 00191 UI.Common.TableManagement.InitializeMaskListByCategorySubcategoryAndType( 00192 this.DDLmask 00193 , this.SelectedCategory 00194 , this.SelectedSubcategory 00195 , DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.ListWithFilter]); 00196 00197 this.SetControllsProperties(); 00198 } 00205 protected void DDLsubcategory_SelectedIndexChanged(object sender, EventArgs e) 00206 { 00207 UI.Common.TableManagement.InitializeMaskListByCategorySubcategoryAndType( 00208 this.DDLmask 00209 , this.SelectedCategory 00210 , this.SelectedSubcategory 00211 , DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.ListWithFilter]); 00212 } 00219 protected void CBcreateDynamicMask_OnCheckedChanged(object sender, EventArgs e) 00220 { 00221 this.SetControllsProperties(); 00222 } 00230 protected void BTNsave_Click(object sender, EventArgs e) 00231 { 00232 string returnMessage = string.Empty; 00233 bool success = this.ValidateData(ref returnMessage); 00234 if (success) 00235 { 00236 RAIS.Common.TableManagement.Table table = this.GetTableFromMask(null); 00237 00238 string maskName = (this.RBnewMenuItem.Checked) 00239 ? table.Name 00240 : this.SelectedMask.Name; 00241 00242 string dynamicMaskName = table.Name; 00243 00244 success = RAIS.ApplicationLogicLayer.TableManagement.AddTable(table 00245 , this.SelectedTableGroup 00246 , maskName 00247 , this.SelectedSubcategory.ID 00248 , (this.DDLdynamicMaskType.Visible) 00249 ? this.SelectedDynamicMaskType 00250 : null 00251 , dynamicMaskName 00252 , this.RBexistingMenuItem.Checked 00253 , this.CBcreateDynamicMask.Checked 00254 , ref returnMessage); 00255 00256 if (success) 00257 { 00258 this.Session[RAIS.UI.Common.Constants.TABLES_TAG] = null; 00259 Response.Redirect(string.Format("~/CustomTables3_New.aspx?{0}={1}" 00260 , Constants.TABLE_ID_PARAMETER_NAME, table.ID)); 00261 } 00262 } 00263 00264 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, 00265 returnMessage, 00266 success); 00267 } 00274 protected void RBmenuItemType_CheckedChanged(object sender, EventArgs e) 00275 { 00276 string selectedMaskType = string.Empty; 00277 if (this.RBnewMenuItem.Checked) 00278 UI.Common.TableManagement.InitializeMaskListByCategoryAndSubcategory(this.DDLmask, this.SelectedCategory, this.SelectedSubcategory); 00279 else 00280 UI.Common.TableManagement.InitializeMaskListByCategorySubcategoryAndType( 00281 this.DDLmask 00282 , this.SelectedCategory 00283 , this.SelectedSubcategory 00284 , DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.ListWithFilter]); 00285 00286 UI.Common.TableManagement.InitializeDynamicMaskTypeList(this.DDLdynamicMaskType, this.RBnewMenuItem.Checked); 00287 //if (this.RBnewMenuItem.Checked) 00288 // selectedMaskType = DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.SingleRowMaskWithList].VisibleName; 00289 //else 00290 // selectedMaskType = DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.SingleRowMask].VisibleName; 00291 //UI.Common.TableManagement.SetDynamicMaskTypeListCurrentSelection(this.DDLdynamicMaskType, selectedMaskType); 00292 this.SetControllsProperties(); 00293 } 00300 protected void DDLtabletype_SelectedIndexChanged(object sender, EventArgs e) 00301 { 00302 this.SetControllsProperties(); 00303 } 00310 protected void LBTNlogout_Click(object sender, EventArgs e) 00311 { 00312 UI.Common.AccessManagement.SignOut(this); 00313 } 00320 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) 00321 { 00322 UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1); 00323 } 00324 #endregion Event handlers 00325 //********************************************************************* 00326 #region Private helper methods 00327 00333 RAIS.Common.TableManagement.Table GetTableFromMask(RAIS.Common.TableManagement.Table table) 00334 { 00335 if (table == null) 00336 table = new RAIS.Common.TableManagement.Table(); 00337 00338 table.Name = this.TXTtablename.Text; 00339 table.TypeText = this.DDLtabletype.SelectedValue; 00340 00341 return table; 00342 } 00349 bool ValidateData(ref string returnMessage) 00350 { 00351 if (this.TXTtablename.Text.Length > 0) 00352 if (this.SelectedSubcategory != null) 00353 { 00354 if (this.RBexistingMenuItem.Checked && this.SelectedMask == null) 00355 { 00356 returnMessage = RAIS.Common.Messages.MASk_MISSING; 00357 return false; 00358 } 00359 else 00360 { 00361 return true; 00362 } 00363 } 00364 else 00365 { 00366 returnMessage = RAIS.Common.Messages.SUBCATEGORY_MISSING; 00367 return false; 00368 } 00369 else 00370 { 00371 returnMessage = RAIS.Common.Messages.TABLE_NAME_MISSING; 00372 return false; 00373 } 00374 } 00378 void SetControllsProperties() 00379 { 00380 DDLsubcategory.Enabled = true; 00381 DDLcategory.Enabled = true; 00382 if (SelectedTableType == RAIS.Common.TableManagement.Table.TableType.Authorization) 00383 { 00384 DDLcategory.SelectedValue = RAIS.Common.Constants.CATEGORY_NAME_INPUT; 00385 DDLcategory.Enabled = false; 00386 UI.Common.TableManagement.InitializeSubcategoryListByCategory(this.DDLsubcategory, this.SelectedCategory, this.ShowProtectors, this.ShowEvaluators); 00387 DDLsubcategory.SelectedValue = "Authorizations"; 00388 DDLsubcategory.Enabled = false; 00389 } 00390 00391 this.FSdynamicMaskProperties.Visible = this.CBcreateDynamicMask.Checked; 00392 if (this.SelectedCategory.Name == RAIS.Common.Constants.CATEGORY_NAME_INPUT 00393 && this.SelectedTableType == RAIS.Common.TableManagement.Table.TableType.Single ) 00394 { 00395 this.RBnewMenuItem.Enabled = true; 00396 this.RBexistingMenuItem.Enabled = true; 00397 } 00398 else 00399 { 00400 this.RBnewMenuItem.Checked = true; 00401 this.RBexistingMenuItem.Checked = false; 00402 00403 this.RBnewMenuItem.Enabled = false; 00404 this.RBexistingMenuItem.Enabled = false; 00405 } 00406 00407 this.DDLmask.Visible = !this.RBnewMenuItem.Checked; 00408 00409 bool dynamicMaskTypeVilible = ( 00410 this.SelectedTableType == RAIS.Common.TableManagement.Table.TableType.Single 00411 && this.SelectedCategory.Name != RAIS.Common.Constants.CATEGORY_NAME_REGULATORY_SYSTEM); 00412 this.LBLdynamicMaskType.Visible = dynamicMaskTypeVilible; 00413 this.DDLdynamicMaskType.Visible = dynamicMaskTypeVilible; 00414 } 00415 #endregion Private helper methods 00416 } 00417 }